layui.config({
	base : "js/"
}).use(['form','layer'],function(){
	var form = layui.form(),
		layer = parent.layer === undefined ? layui.layer : parent.layer,
		$ = layui.jquery;
	//video背景
	$(window).resize(function(){
		if($(".video-player").width() > $(window).width()){
			$(".video-player").css({"height":$(window).height(),"width":"auto","left":-($(".video-player").width()-$(window).width())/2});
		}else{
			$(".video-player").css({"width":$(window).width(),"height":"auto","left":-($(".video-player").width()-$(window).width())/2});
		}
	}).resize();

    form.verify({
        username: function(value){
            if(value.length < 1){
                return '用户名不能为空';
            }
        },
        password: function(value){
            if(value.length < 1){
                return '密码不能为空';
            }
        }
    });
    $(document).on("click",'#loginButton','form[data-type=ajax]',function(){
        //var url = $(this).attr('action');
        var data = $(this).serializeArray();
        $.ajax({
            type: "POST",
            dataType: "json",
            url:"/ajaxLogin",
            data:$("#loginForm").serialize() ,
            success: function (obj) {
                if(!(obj.errType=="0000")){
                    layer.msg(obj.errMsg);
                }
                else{
                   // layer.msg(obj.errMsg);
                    window.location.href = "../../index.html";
                }
            },
            error: function(data) {
                layer.msg("网络错误");
            }
        });
        return false;
    });
})
